<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>animated动画</title>
    <link rel="stylesheet" href="./animate.css">
    <script src="./vue.js"></script>

    <style>
        /* @keyframes moving {
            0% {
                transform: scale(0)
            }

            50% {
                transform: scale(2)
            }

            100% {
                transform: scale(1)
            }
        } */
        /* .active {
            transform-origin: left center;
          
            animation: moving 2s
        }

        .leave {
            transform-origin: left center;
            animation: moving 2s reverse;
        } */
        /* .fade-enter {
            opacity: 0;
        }

        .fade-enter-active {
            transition: all 3s ease-in-out;
        }

        .fade-leave-to {
            opacity: 0;
        }

        .fade-leave-active {
            transition: all 3s ease-in-out;
        } */
    </style>
</head>

<body>
    <div id="app">
        <h2>增加appear 实现一进来就有动画效果</h2>

        <transition @before-leave="beforLeaveHandle" @leave="LeaveHandel" @after-leave='afterLeaveHandel'>

            <div v-show="flag">hello world</div>

        </transition>
        <button @click="change">切换动画</button>

    </div>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                flag: true
            },
            methods: {
                change() {
                    this.flag = !this.flag
                },
                beforLeaveHandle(el) {
                    // alert(1)
                    // el 表示被transition标签包裹的div 元素
                    el.style.color = 'red'
                },
                LeaveHandel(el, done) {
                    setTimeout(() => {
                        el.style.fontSize = "50px"
                        el.style.backgroundColor = "black"
                    }, 2000)

                    setTimeout(() => {
                        done()
                    }, 4000)
                },
                afterLeaveHandel(el) {
                    el.style.fontSize = '16px';
                    el.style.backgroundColor = ""
                }
            }
        })
    </script>
</body>

</html>